from Page.register import register
from Page.register2 import register2
from Page.login import login
from Page.login2 import login2

from selenium import webdriver
from selenium.webdriver.common.by import By
import unittest,time
class TestCase(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.maximize_window()

    def tearDown(self):
        time.sleep(4)
        self.driver.quit()
    def test_mine_01(self):
        po = register(self.driver)
        po.open_url('http://localhost:8080/register')
        po.user()
        po.pwd()
        po.sure()
        time.sleep(3)
        po.alert_sure()
        time.sleep(3)
        self.driver.refresh()
        dy = self.driver.find_element(By.XPATH,'/html/body/div[1]/div/section/section/main/form/div/div[1]/div/label').text
        print(dy)
        self.assertIn('模块名',dy)
        self.assertNotIn('用户名',dy)
    def test_mine_02(self):
        po = register2(self.driver)
        po.open_url('http://localhost:8080/register')
        po.user()
        po.pwd()
        po.sure()
        time.sleep(3)
        po.alert_sure()
        time.sleep(3)
        self.driver.refresh()
        dy = self.driver.find_element(By.XPATH,'/html/body/div[1]/div/section/section/main/form/div[1]/label').text
        print(dy)
        self.assertIn('用户名',dy)
        self.assertNotIn('模块名', dy)
    def test_mine_03(self):
        po = login(self.driver)
        po.open_url('http://localhost:8080/login')
        po.user()
        po.pwd()
        po.sure()
        po.agree()
        time.sleep(3)
        time.sleep(3)
        self.driver.refresh()
        dy = self.driver.find_element(By.XPATH,
                                      '/html/body/div[1]/div/section/section/main/form/div/div[1]/div/label').text
        print(dy)
        self.assertIn('模块名', dy)
        self.assertNotIn('用户名', dy)
    def test_mine_04(self):
        po = login2(self.driver)
        po.open_url('http://localhost:8080/login')
        po.user()
        po.pwd()
        po.sure()
        po.agree()
        time.sleep(3)
        po.alert_sure()
        time.sleep(3)
        self.driver.refresh()
        dy = self.driver.find_element(By.XPATH,
                                      '/html/body/div[1]/div/section/section/main/div[1]/div[2]/button[2]').text
        print(dy)
        self.assertIn('立即登录', dy)
        self.assertNotIn('模块', dy)




if __name__ == '__main__':
    unittest.main()